* Table 'res_currency_rate': unable to add constraint 'res_currency_rate_unique_name_per_day' as unique (name,currency_id,company_id)

DELETE FROM res_currency_rate R1
    USING res_currency_rate R2
WHERE R1.id < R2.id
    AND R1.name = R2.name
    AND R1.currency_id = R2.currency_id
    AND R1.company_id = R2.company_id;

* Table 'hr_work_location': unable to set NOT NULL on column 'address_id'

update hr_work_location
SET address_id = res_company.partner_id FROM res_company
WHERE res_company.id = 1 AND hr_work_location.address_id is Null

* Table 'product_packaging': unable to set NOT NULL on column 'name'

update product_packaging
SET name = 'BOXES'
WHERE product_packaging.name is Null

* Table 'hr_leave_allocation': unable to add constraint 'hr_leave_allocation_duration_check' as CHECK( ( number_of_days > 0 AND allocation_type='regular') or (allocation_type != 'regular'))

DELETE FROM public.hr_leave_allocation
WHERE number_of_days = 0 AND allocation_type='regular'

* Table 'account_payment': unable to add constraint 'account_payment_check_amount_not_negative' as CHECK(amount >= 0.0)

UPDATE account_payment
SET (amount, payment_type) = (-amount, 'inbound') WHERE amount < 0 AND payment_type = 'outbound'

UPDATE account_payment
SET (amount, payment_type) = (-amount, 'outbound') WHERE amount < 0 AND payment_type = 'inbound'

* Table 'account_account_type': unable to set NOT NULL on column 'internal_group'

UPDATE account_account_type
SET internal_group = 'equity' WHERE internal_group is null AND name = 'Capital'

UPDATE account_account_type
SET internal_group = 'off_balance' WHERE internal_group is null AND name = 'View'

* Table 'hr_expense_sheet': unable to add constraint 'hr_expense_sheet_journal_id_required_posted' as CHECK((state IN ('post', 'done') AND journal_id IS NOT NULL) OR (state NOT IN ('post', 'done')))

UPDATE hr_expense_sheet SET journal_id = 12 WHERE journal_id is null